import 'package:flutter/material.dart';
import 'package:flutter_wechat/address_book_page.dart';
import 'package:flutter_wechat/discover_page.dart';
import 'package:flutter_wechat/home_page.dart';
import 'package:flutter_wechat/mine_page.dart';

class RootPage extends StatefulWidget {
  const RootPage({super.key});

  @override
  _RootPageState createState() => _RootPageState();
}

class _RootPageState extends State<RootPage> {

  int _currentIndex = 0;

  final _pages = [HomePage(), AddressBookPage(), DiscoverPage(), MinePage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.chat), label: "home"),
          BottomNavigationBarItem(
              icon: Icon(Icons.bookmark), label: "addressBook"),
          BottomNavigationBarItem(icon: Icon(Icons.history), label: "discover"),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: "mine"),
        ],
      ),
    );
  }
}
